
#include "../include/_PI_Cale.h"

#include <iostream>
#include <vector>
#include <list>
#ifdef _win64系统
#include <windows.h>
#else
#include <ctime>
#endif

using namespace std;

#define π 3.141592653589793238462643383279

#define 步长 1000 //us
#define 周期 1000 //ms
#define 周期数 1



int main()
{

    const int 点数 = 周期 * 1000 * 周期数 / 步长;
    float x[点数];
    int x2[点数];
    float out[点数];
    void *p1 = PI_Creat();
    void *p2 = PI_Creat();
    for (int i = 0; i < 点数; i++)
    {
        switch (i)
        {
        case (int)(0.0 * 点数)...(int)(0.2 * 点数):
            x[i] = 8; x2[i] = 0;
            break;
        case (int)(0.2 * 点数) + 1 ...(int)(0.4 * 点数):
            x[i] = 8;x2[i] = 1;
            break;
        case (int)(0.4 * 点数) + 1 ...(int)(0.6 * 点数):
            x[i] = 8;x2[i] = 0;
            break;
        case (int)(0.6 * 点数) + 1 ...(int)(0.8 * 点数):
            x[i] = -7;x2[i] = 0;
            break;
        case (int)(0.8 * 点数) + 1 ...(int)(1.0 * 点数):
            x[i] = -7;x2[i] = 1;
            break;
        default:
            x[i] = 0;x2[i] = 0;
            break;
        }
    }

    // 计时
#ifdef _win64系统
    LARGE_INTEGER t1, t2, tc;
    QueryPerformanceFrequency(&tc);
    QueryPerformanceCounter(&t1);
#else
    clock_t time_start = clock();
#endif
    // 计时👆

    for (int i = 0; i < 点数; i++)
    {
        //auto usin = sin( i*2*π/(周期*1000.0/(double)步长)  );
        float y;
        PI_Cal(
            (PI *)p1,
            x[i],
            x2[i],
            1,
            10,
            10,
            -10,
            0,
            (float)步长 / 1e6,
            &y);
        out[i] = y;
    }

   // 计时
    #ifdef _win64系统
    QueryPerformanceCounter(&t2);
    auto time = (double)(t2.QuadPart - t1.QuadPart) / (double)tc.QuadPart;
    cout << "点数：" << 点数 <<endl;
    cout << "time =  " << 1000.0 * time << "  ms" << endl; //输出时间（单位：ｓ）
    cout<<endl;
    cout<<endl;
    #else
    clock_t time_end = clock();
    cout << "点数：" << 点数 <<endl;
    cout << "time =  " << 1000.0 * (time_end - time_start) / (double)CLOCKS_PER_SEC << "  ms" << endl; //输出时间（单位：ｓ）
    cout << endl;
    cout << endl;    
#endif
    // 计时👆

    for (int i = 点数 * 0.0; i < 点数; i++)
    {
        cout << "输入： " << x[i] << "  更新值： " << x2[i]
             << "  时间" << i * 步长 / 1000.0 << "ms  "
             << "  y： " << out[i] << "   幅值： " << endl;
    }

    system("pause");
    }
